/**
 * 
 */
package com.ubo.graphviz.model.graph.statement;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.ubo.transform.dot.IDotVisitor;


/**
 * @author saludegu
 * 
 */
public class Subgraph implements IStatement {

	/**
	 * Nom du sous-graphe.
	 */
	protected String mName;

	/**
	 * Liste des statements contenus dans le sous graphe.
	 */
	protected List<IStatement> mStatements;

	/**
	 * Attribute du sous-graphe.
	 */
	protected Attribute mAttribute;

	/**
	 * Label du sous-graphe.
	 */
	protected String mLabel;

	/**
	 * 
	 * Constructor
	 * 
	 * @param name
	 */
	public Subgraph(String name) {
		mName = name;
	}

	/**
	 * @return the mName
	 */
	public String getName() {
		return mName;
	}

	/**
	 * @param mName
	 *            the mName to set
	 */
	public void setName(String mName) {
		this.mName = mName;
	}

	/**
	 * @return the mStatements
	 */
	public List<IStatement> getStatements() {
		return mStatements;
	}

	public void addStatement(IStatement iStatement) {
		if (mStatements == null)
			mStatements = new ArrayList<IStatement>();
		mStatements.add(iStatement);
	}

	public void addAllStatements(Collection<IStatement> statements) {
		if (mStatements == null)
			mStatements = new ArrayList<IStatement>();
		mStatements.addAll(statements);
	}

	/**
	 * @return the mAttribute
	 */
	public Attribute getAttribute() {
		return mAttribute;
	}

	/**
	 * @param mAttribute
	 *            the mAttribute to set
	 */
	public void setAttribute(Attribute mAttribute) {
		this.mAttribute = mAttribute;
	}

	/**
	 * @return the mLabel
	 */
	public String getLabel() {
		return mLabel;
	}

	/**
	 * @param mLabel
	 *            the mLabel to set
	 */
	public void Label(String mLabel) {
		this.mLabel = mLabel;
	}

	/**
	 * @see com.ubo.graphviz.model.graph.statement.IStatement#generate(com.ubo.transform.dot.IDotVisitor)
	 */
	@Override
	public void generate(IDotVisitor<?> visitor) {
		visitor.generate(this);
	}
}
